package mspbots.hubspot.client.core.companies;

import com.fasterxml.jackson.databind.JsonNode;
import lombok.RequiredArgsConstructor;
import mspbots.hubspot.common.QueryBody;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

import javax.validation.Valid;

/**
 * data.connector.hubspot.api.contatct.ContactController
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2020/3/31
 */
@RestController
@RequestMapping("companies/{tenantId}")
@RequiredArgsConstructor
public class CompaniesController {

    private final CompaniesServiceImpl companiesService;

    @GetMapping("properties")
    public Flux<JsonNode> properties(@PathVariable Long tenantId) {
        return this.companiesService.properties(tenantId);
    }


    @PostMapping("search")
    public Flux<JsonNode> search(@PathVariable Long tenantId, @Valid @RequestBody QueryBody queryBody) {
        return this.companiesService.search(tenantId, queryBody);
    }

}
